<?php
/**
 * @version		0.2.0 joomla zmluvy $
 * @package		com_zjmluvy
 * @copyright	Copyright © 2011 - All rights reserved.
 * @license		GNU/GPL
 * @author    AdrianKo		
 * @website   http://code.google.com/p/joomla-zmluvy
 *
 *
 *1.3.2012
 */

// no direct access
defined('_JEXEC') or die('Restricted access');
  
JHTML::_('behavior.tooltip'); 
	JToolBarHelper::title( JText::_( '&nbsp;&nbsp;&nbsp;'.JText::_( 'TITLE_OBJEDNAVKY_EDIT' )), 'objednavky' );
  
  //*** podmienky pre zobrazenie ikony pre zmazanie dokumentov
  if (!empty($this->item->file)) {
    JToolBarHelper::customX( 'deletefile', 'delete','','Zmazat sken', false);
  }
  if (!empty($this->item->file2)) {
    JToolBarHelper::customX( 'deletefile2', 'delete','','Zmazat TXT/OCR', false);
  }
  JToolBarHelper::save();
	JToolBarHelper::apply();
	if (JRequest::getVar('edit')) {
		JToolBarHelper::cancel( 'cancel', 'Close' );
	} else {
		JToolBarHelper::cancel();
	}
//	JToolBarHelper::help( 'screen.users' );
  $editor =& JFactory::getEditor();
  
  //*** zameni hodnotu v datume z 0000-00-00 za vlastne v confug.xml
  $platnost = 0;
  if ($this->item->publish_up == '0000-00-00' || $this->item->publish_up == 0) {
    $platnost = 1;
    $this->item->publish_up = $this->nastavenie->datum_text;
  } 
  if ($this->item->datUhrady == '0000-00-00' || $this->item->datUhrady == 0) {
    $platnost = 1;
    $this->item->datUhrady = $this->nastavenie->datum_text;
  }
  if ($this->item->datZver == '0000-00-00' || $this->item->datZver == 0) {
    $platnost = 1;
    $this->item->datZver = $this->nastavenie->datum_text;
  }      

?>	
<form action="index.php" method="post" name="adminForm" enctype="multipart/form-data">		
  <div class="col width-60">			
    <fieldset class="adminform">				
      <legend>
        <?php echo JText::_( 'zm_EDIT_BLOK_ZMY' ); ?>
      </legend>					
      <table class="admintable">				            	
        <tr>						
          <td class="key">							
            <label for="faktura" width="100">								
              <?php echo JText::_( 'obj_CISLO_OBJEDNAVKY' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						  
            <input id="faktura" class="text_area" name="faktura" title="<?php echo JText::_( '' ); ?>" value="<?php echo $this->item->faktura; ?>" size="30" maxlength="50" />
            <?php // echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?>
          </td>
        </tr>

        <tr>                      	
          <td class="key">							
            <label  width="100">								
              <?php echo JText::_( 'obj_PARTNER' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">							
            <?php echo $this->lists['dod']; ?>
            <?php echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?>
            <?php echo "<a title='".JText::_( '' )."' href='index.php?option=com_jzmluvy&view=upravapartner&task=edit&id[]=0'>".JText::_( 'fa_EDIT_NOVY' )."</a>" ?>
          </td>					
        </tr>
        
        <tr>						
          <td class="key">							
            <label for="title" width="100">								
              <?php echo JText::_( 'obj_POPIS_PLNENIA' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						  
            <textarea id="title" class="text_area" name="title" cols="50" rows="3" title="<?php echo JText::_( '' ); ?>"><?php echo $this->item->title; ?></textarea>						
            <?php echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?>
          </td>					
        </tr> 
                                       
        <tr>						
          <td class="key">							
            <label for="suma" width="100">								
              <?php echo JText::_( 'zm_SUMA' ); ?> <?php if($this->nastavenie->dph) { echo JText::_( 'OBJ_SDPH' ); } else { echo JText::_( 'OBJ_BEZDPH' ); } ?>: 							
            </label>
          </td>						
          <td colspan="2">						  
            <input id="suma" class="text_area" name="suma" title="<?php echo JText::_( 'Suma' ); ?>" value="<?php echo $this->item->suma; ?>" size="30" maxlength="50" />										
            <input id="mena" class="text_area" name="mena" title="<?php echo JText::_( 'Mena' ); ?>" value="<?php echo $this->item->mena; ?>" size="10" maxlength="10" />
            <?php echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?>
          </td>
        </tr> 
          
        <?php if($this->nastavenie->crz) : ?>
        <tr> 
          <td class="key"> 
            <label title="<?php echo JText::_( 'ZM_IDENT_ZMLUVY_RZ_I' ); ?>">
              <?php echo JText::_( 'zm_ident_zmluvy_rz' ).":"; ?>
            </label></td> 
          <td> 
            <input id="jedcislo" class="text_area" name="jedcislo" title="<?php echo JText::_( 'zm_ident_zmluvy_rz_zmluva' ); ?>" value="<?php echo $this->item->jedcislo; ?>" size="10" maxlength="50" />
            http://<input id="intCislo" class="text_area" name="intCislo" title="<?php echo JText::_( 'ZM_IDENT_ZMLUVY_RZ_LINK');   ?>" value="<?php echo $this->item->intCislo; ?>" size="40" maxlength="80" />
          </td>
        </tr>
        <?php endif; ?>  

        <tr> 
          <td class="key"> 
            <label>
              <?php if ($this->item->typ) : ?>                            
              <?php echo "<a title='".JText::_( '' )."' href='index.php?option=com_jzmluvy&view=upravazmluvy&task=edit&id[]=".$this->item->typ."'>".JText::_( 'zm_ident_zmluvy' )."</a>:"; ?>
              <?php else : ?>
              <?php echo JText::_( 'zm_ident_zmluvy' ).":"; ?>
              <?php endif; ?>
            </label>
          </td> 
          <td> 
            <?php echo $this->lists['dodatok']; ?><br />
          </td>
        </tr>  

        <?php if($this->nastavenie->kontakty) : ?>          
        <tr>						
          <td class="key">							
            <label for="created_by_alias" width="100">								
              <?php echo JText::_( 'obj_VYSTAVIL' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						
            <?php echo $this->lists['kontakty']; ?>
             <?php echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?> 						</td>					
        </tr>					
        <?php else: ?>
        <tr>						
          <td class="key">							
            <label for="vlastni1" width="100">								
              <?php echo JText::_( 'obj_VYSTAVIL' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						  
            <input id="vlastni1" class="text_area" name="vlastni1" title="<?php echo JText::_( '' ); ?>" value="<?php echo $this->item->vlastni1; ?>" size="80" maxlength="150" />
             <?php echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?>
          </td>					
        </tr>

        <tr>
          <td class="key">							
            <label for="vlastni2" width="100">								
              <?php echo JText::_( 'obj_FUNKCIA' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						  
            <input id="vlastni2" class="text_area" name="vlastni2" title="<?php echo JText::_( '' ); ?>" value="<?php echo $this->item->vlastni2; ?>" size="80" maxlength="150" />
          </td>					
        </tr>        
        <?php endif; ?>     		 
      </table>
  </fieldset>
           
    <fieldset class="adminform">				
      <legend>
        <?php echo JText::_( 'zm_datumy' ); ?>
      </legend>					
        <table class="admintable">	           
          <tr>						
            <td class="key">							
              <label for="datUhrady" width="100">								
                <?php echo JText::_( 'obj_DAT_VYHOTOVENIA' ); ?>: 							
              </label>
            </td>
            <td>
              <?php echo JHTML::_('calendar', jzmluvyHelper::datdmy($this->item->datUhrady), "datUhrady", "datUhrady", '%d.%m.%Y'); ?> 
              <?php echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?>
            </td>
          </tr>

          <tr>						
            <td class="key">							
              <label for="datZver" width="100">								
                <?php echo JText::_( 'zm_DAT_ZVEREJNENIA' ); ?>: 							
              </label>
            </td>
            <td>					
              <?php echo JHTML::_('calendar', jzmluvyHelper::datdmy($this->item->datZver), "datZver", "datZver", '%d.%m.%Y'); ?> 
              <?php echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?>
            </td>
          </tr>
       
          <?php if($this->nastavenie->obj_dat_plnenia) : ?>
          <tr>
            <td class="key">							
              <label for="publish_up" width="100">								
                <?php  echo JText::_( 'obj_DAT_DODANIA' ); ?>: 							
              </label>
            </td>
            <td>
              <?php  echo JHTML::_('calendar', jzmluvyHelper::datdmy($this->item->publish_up), "publish_up", "publish_up", '%d.%m.%Y'); ?>             
              <?php  // echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?>
            </td>
          </tr>
          <?php endif ?>
        </table>
    </fieldset>       					

    <fieldset class="adminform">				
      <legend>
        <?php if($this->nastavenie->subory) { echo JText::_( 'zm_DOK' ); } else { echo JText::_( 'zm_DOK_BEZ' ); } ?>
      </legend>					
      <table class="admintable">

        <?php  if($this->nastavenie->subory) : ?>      
         <tr>						
           <td class="key">							
             <label for="file" width="100">								
               <?php echo JText::_( 'zm_EDIT_SUBOR_SKEN' ); ?>: 							
             </label>
           </td>						
           <td colspan="2">						  
             <?php if (empty($this->item->file)) { ?>							
               <input type="file" name="soubor" style="width: 300px;" />							
             <?php } else { ?>
             <?php echo jzmluvyHelper::ikona ($this->item->extension,$this->item->file).' '.$this->item->file; ?>
             <?php echo '<input type="hidden" name="soubor" value="'.$this->item->file.'" />'; ?>
             <?php } ?>
           </td>					
         </tr>					
         <tr>						
           <td class="key">							
             <label for="file2" width="100">								
               <?php echo JText::_( 'zm_EDIT_SUBOR_TXT' ); ?>: 							
             </label>
           </td>						
           <td colspan="2">						  
             <?php if (empty($this->item->file2)) { ?>							
               <input type="file" name="soubor2" style="width: 300px;" />							
               <?php } else { ?>
               <?php echo jzmluvyHelper::ikona ($this->item->extension2,$this->item->file2).' '.$this->item->file2; ?>
               <?php  echo '<input type="hidden" name="soubor2" value="'.$this->item->file2.'" />'; ?>
               <?php } ?>
           </td>					
         </tr>           					 				
		     <?php endif; ?>	
        
         <tr>						
           <td class="key">							
            <label for="poznamka" width="100">								
              <?php echo JText::_( 'obj_POZNAMKA' ); ?>: 							
            </label>
           </td>
           <td>							
             <textarea id="poznamka" class="text_area" name="poznamka" cols="55" rows="3" title="<?php echo JText::_( 'Poznámka' ); ?>"><?php echo $this->item->poznamka; ?></textarea>
           </td>
        </tr>					
      </table>			
    </fieldset>		
  </div>
  
  <?php //*** blok na pravo info a statistika 
  if($this->item->id != '') { ?>
  <div style="float:right;" class="col width-30">			
    <fieldset class="adminform">				
      <legend>
        <?php echo JText::_( 'FA_EDIT_BLOK_STAT' ); ?>
      </legend>					
      <table class="admintable">				            	
        <tr>						
          <td class="key">							
            <label for="title" width="100">								
              <?php echo JText::_( 'FA_EDIT_STAT_VYTVORIL' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						  
            <?php echo jzmluvyHelper::uzivatel($this->item->id)->vytvoril;?></td>					
        </tr>
        <tr>						
          <td class="key">							
            <label for="title" width="100">								
              <?php echo JText::_( 'FA_EDIT_STAT_DAT_VYTVORENIA' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						  
            <?php echo $this->item->created; ?>
          </td>					
        </tr>
       
          <?php if($this->item->modified != 0 ) { ?>
          <tr>						
          <td class="key">							
            <label for="title" width="100">								
              <?php echo JText::_( 'FA_EDIT_STAT_UPRAVIL' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						  
            <?php echo jzmluvyHelper::uzivatel($this->item->id)->zmenil;?>
          </td>					
        </tr>
        
        <tr>						
          <td class="key">							
            <label for="title" width="100">								
              <?php echo JText::_( 'FA_EDIT_STAT_DAT_UPRAVY' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						  
            <?php echo $this->item->modified; ?>
          </td>					
        </tr>
        <?php } ?>
       
        <tr>						
          <td class="key">							
            <label for="title" width="100">								
              <?php echo JText::_( 'FA_EDIT_STAT_POCET_ZOBRAZENI' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						  
            <input id="hits_detail" class="text_area" name="hits_detail" title="<?php echo JText::_( 'pocet_zobrazeni' ); ?>" value="<?php echo $this->item->hits_detail; ?>" size="10" maxlength="50" />&nbsp;krát
          </td>					
        </tr>
                
        <?php if($this->item->hits != 0 || $this->item->filename != '') { ?>
        <tr>						
          <td class="key">							
            <label for="title" width="100">								
              <?php echo JText::_( 'Stiahnuty scan subor' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						  
            <input id="hits" class="text_area" name="hits" title="<?php echo JText::_( 'pocet_stiahnut_scan' ); ?>" value="<?php echo $this->item->hits; ?>" size="10" maxlength="50" />&nbsp;krát
          </td>					
        </tr>
       <?php } ?>
        
        <?php if($this->item->hits2 != 0 || $this->item->filename2 != '') { ?>
        <tr>						
          <td class="key">							
            <label for="title" width="100">								
              <?php echo JText::_( 'Stiahnuty textovy subor' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						  
            <input id="hits2" class="text_area" name="hits2" title="<?php echo JText::_( 'pocet_stiahnut_text' ); ?>" value="<?php echo $this->item->hits2; ?>" size="10" maxlength="50" />&nbsp;krát
          </td>					
        </tr>                      	
        <?php } ?>        						
      </table>
    </fieldset>
  </div>
  <?php } ?> 
        		
  <div class="clr">
  </div>		
  <input type="hidden" name="option" value="com_jzmluvy" />		
  <input type="hidden" name="controller" value="upravaobjednavky" />		
  <input type="hidden" name="id" value="<?php echo $this->item->id; ?>" /> 		
  <input type="hidden" name="task" value="edit" />		
  <input type="hidden" name="redirect" value="<?php //echo $redirect; ?>" />		
  <?php echo JHTML::_( 'form.token' ); ?>		
</form>